package qingke.me.jdbc;

import java.awt.print.PrinterAbortException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Arrays;

public class JdbcBatch extends JdbcConn {
	public static void main(String[] args) {
		Connection conn = null;
		PreparedStatement ps = null;
		
		try {
			conn = getConnection();
			ps = conn.prepareStatement("insert into qixi.school(id,name,code)values(?,?,?)");
			for(int i=1;i<=20;i++){
				ps.setInt(1,108+i);
				ps.setString(2,"ѧУ"+i );
				ps.setString(3,"ѧУ"+i );
				ps.addBatch();
			}
			int[] results = ps.executeBatch();
			System.out.println("result = "+Arrays.toString(results));
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
